﻿#include "WRWorkService.h"
#include "WRWorkObjectType.h"
#include "WRWorkServiceType.h"
#include "WRWorkServiceUuids.h"

//获取工作服务类型。
WRType* WRTypes::workService(void)
{
    static WRType* type = WRType::enroll(WRWorkServiceType, WRTypes::workObject());
    return type;
}
//获取工作只可本地控制服务类型。
WRType* WRTypes::workLocalControlService(void)
{
    static WRType* type = WRType::enroll(WRWorkLocalControlServiceType, WRTypes::workService());
    return type;
}

//初始化工作服务。
WRWorkService::WRWorkService(const WRWorkInformation& info, WRWorkDaemon* daemon)
    : WRWorkObject(info, daemon)
{
    m_switchDealer.target(this);
}
//当前对象所占用的相关资源。
WRWorkService::~WRWorkService(void)
{
    //add code here
}

//获取当前服务的类型。
WRType* WRWorkService::type(void) const
{
    return WRTypes::workService();
}

//查询指定标识的任务处理者。
WRTaskDealer* WRWorkService::queryTaskDealer(const QUuid& uuid)
{
    if (uuid == WRWorkSwitchDealer)
    {
        return &m_switchDealer;
    }
    return WRWorkObject::queryTaskDealer(uuid);
}
//查询指示标识的状态源接口。
WRStateSource* WRWorkService::queryStateSource(const QUuid& uuid)
{
    if (uuid == WRWorkStatusSource)
    {
        return &m_statusHandlers;
    }
    return WRWorkObject::queryStateSource(uuid);
}
